
class HomeView extends eui.Component {
    public constructor() {
        super();
    }
    private rect: eui.Rect;
    private btn1: eui.Button;
    private btn2: eui.Button;
    private ani: egret.tween.TweenGroup;


    protected createChildren(): void {
        super.createChildren();
        this.skinName = "resource/skin/HomeViewSkin.exml";
    }

    protected childrenCreated(): void {
        super.childrenCreated();
        this.showAnimate();
        this.addEvents();
    }

    private addEvents(): void {
        this.btn1.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClickBtn1, this);
        this.btn2.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onClickBtn2, this);
    }

    private removeEvents(): void {
        this.btn1.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onClickBtn1, this);
        this.btn2.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onClickBtn2, this);
    }

    private onClickBtn1(): void {
        let list = new ScoreList();
        this.addChild(list);
    }

    private onClickBtn2(): void {
        let scroller = new myScreen();
        this.addChild(scroller);
    }

    private showAnimate(): void {
        this.ani.items.forEach((v, i, arr) => {
            let item = v as egret.tween.TweenItem;
            if (item) {
                item.props = { loop: true }
            }
        }, this);
        this.ani.play();
    }

    public dispose(): void {
        this.removeEvents();
    }
}